package com.study.seckill.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.study.seckill.entity.CourseSeckill;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @ClassName: CourseMapper
 * @Author: wYin
 * @Date: 2022/3/10 14:37
 */
public interface CourseSeckillMapper extends BaseMapper<CourseSeckill> {

    @Select("select * from course_seckill where show_time<now() and end_time>now()")
    public List<CourseSeckill> getShowCourseSeckill();
    @Select("select * from course_seckill where show_time<now() and end_time>now() and id=#{id}")
    public CourseSeckill getCourseSeckill(Integer id);

    @Update("update course_seckill set seckill_num = seckill_num-1 where id=#{id} and version=#{version}")
    public boolean  updateSeckillStock(Integer id,String version);
}
